package com.hhc.dto;

import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

/**
 * <p>
 *   REST请求结果封装对象
 * </p>
 * @author pc
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class RestResult<T> {

    private String code;

    private String msg;

    private T data;

    public static <T> RestResult<T> success(T data) {
        RestResult<T> result = new RestResult<>();
        result.setCode("000000");
        result.setMsg("调用成功");
        result.setData(data);
        return result;
    }
    public static <T> RestResult<T> success(String code) {
        RestResult<T> result = new RestResult<>();
        result.setCode("000000");

        return result;
    }

    public static <T> RestResult<T> fail(String code, String msg) {
        RestResult<T> result = new RestResult<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static <T> RestResult<T> failed(String code) {
        RestResult<T> result = new RestResult<>();
        result.setCode(code);
        return result;
    }

}
